﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.40	合同文件信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_LOAN_CONTRACTFILES: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_LOAN_CONTRACTFILES()
		{}
		#region Model
		private long _id;
		private long _conid;
		private long _tmpid;
		private string _contype;
		private string _conno;
		private string _saveurl;
		private string _createby;
		private Nullable<DateTime> _createdate;
		private string _modifyby;
		private Nullable<DateTime> _modifydate;
		private string _lastprint;
		private Nullable<DateTime> _printdate;
		private int _printcount;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 合同记录ID
		/// </summary>
		[DataMember]
		public long CONID
		{
			get{return _conid;}
			set{
				if ( _conid!= value)
				{
					 _conid = value;
					OnPropertyChanged("CONID");
				}
			}
		}
		/// <summary>
		/// 模版记录ID
		/// </summary>
		[DataMember]
		public long TMPID
		{
			get{return _tmpid;}
			set{
				if ( _tmpid!= value)
				{
					 _tmpid = value;
					OnPropertyChanged("TMPID");
				}
			}
		}
		/// <summary>
		/// 合同类型取模版的名称
		/// </summary>
		[DataMember]
		public string CONTYPE
		{
			get{return _contype;}
			set{
				if ( _contype!= value)
				{
					 _contype = value;
					OnPropertyChanged("CONTYPE");
				}
			}
		}
		/// <summary>
		/// 合同编号
		/// </summary>
		[DataMember]
		public string CONNO
		{
			get{return _conno;}
			set{
				if ( _conno!= value)
				{
					 _conno = value;
					OnPropertyChanged("CONNO");
				}
			}
		}
		/// <summary>
		/// 保存路径
		/// </summary>
		[DataMember]
		public string SAVEURL
		{
			get{return _saveurl;}
			set{
				if ( _saveurl!= value)
				{
					 _saveurl = value;
					OnPropertyChanged("SAVEURL");
				}
			}
		}
		/// <summary>
		/// 生成人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 生成时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 修改人
		/// </summary>
		[DataMember]
		public string MODIFYBY
		{
			get{return _modifyby;}
			set{
				if ( _modifyby!= value)
				{
					 _modifyby = value;
					OnPropertyChanged("MODIFYBY");
				}
			}
		}
		/// <summary>
		/// 修改时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> MODIFYDATE
		{
			get{return _modifydate;}
			set{
				if ( _modifydate!= value)
				{
					 _modifydate = value;
					OnPropertyChanged("MODIFYDATE");
				}
			}
		}
		/// <summary>
		/// 最后打印人
		/// </summary>
		[DataMember]
		public string LASTPRINT
		{
			get{return _lastprint;}
			set{
				if ( _lastprint!= value)
				{
					 _lastprint = value;
					OnPropertyChanged("LASTPRINT");
				}
			}
		}
		/// <summary>
		/// 最后打印时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> PRINTDATE
		{
			get{return _printdate;}
			set{
				if ( _printdate!= value)
				{
					 _printdate = value;
					OnPropertyChanged("PRINTDATE");
				}
			}
		}
		/// <summary>
		/// 打印次数
		/// </summary>
		[DataMember]
		public int PRINTCOUNT
		{
			get{return _printcount;}
			set{
				if ( _printcount!= value)
				{
					 _printcount = value;
					OnPropertyChanged("PRINTCOUNT");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

